<template>
	<view class="page" style="height: 100vh;">
		<free-nav-bar showback showright="true" title="用户投诉">

			<view slot="right" class="main-bg-color rounded mr-3 px-2 py-1">
				<text class="font text-white" @click="baocun">投诉</text>


			</view>
		</free-nav-bar>
		<picker mode="selector" :range="range" @change="change">
			<free-list-item :title="cate" :showright="true" isshowjt>
			</free-list-item>
		</picker>

		<textarea name="" style="width: 100%;" v-model="content" placeholder="请填写内容" class="bg-white p-2 font-md" id=""
			cols="30" rows="10"></textarea>
	</view>
</template>

<script>
	import freeNavBar from "@/components/free-ui/free-nav-bar.vue"
	import $H from '../../../utils/request.js';
	import freeListItem from "@/components/free-ui/free-list-item.vue"
	export default {
		components: {
			freeNavBar,
			freeListItem
		},
		data() {
			return {
				reported_id: "",
				reported_type: "",
				category: "",
				content: "",
				range: ["粉丝无底线追星行为", "该账号可能被调用", "存在欺骗诈骗行为", "存在侵权行为", "冒出他人"],
				cate: "请选择分类",
			}
		},
		onLoad(e) {
			if (e.type) {
				this.reported_type = e.type
			}
			if (e.id) {
				this.reported_id = e.id

			}
		},
		methods: {
			baocun() {
				if (this.cate == '请选择分类') {
					return uni.showToast({
						icon: "none",
						title: "请选择分类"
					})
				}
				if (this.content == '') {
					return uni.showToast({
						icon: "none",
						title: "请输入内容"
					})
				}
				$H.post("report/save", {
					reported_id: this.reported_id,
					reported_type: this.reported_type,
					content: this.content,
					category: this.cate

				}, {
					token: true
				}).then(res => {
					console.log(res, "res")
					if (res) {
						uni.navigateBack({
							delta: 1
						})
						uni.showToast({
							icon: "none",
							title: "投诉成功"
						})
					}
				})


			},
			change(e) {
				console.log(e);
				this.cate = this.range[e.detail.value]
			}
		}
	}
</script>

<style>

</style>
